package com.example.demo.controller;


import com.example.demo.entity.Test;
import com.example.demo.service.DemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/demo")
public class DemoController {

    @Autowired
    private DemoService demoService;

    @Autowired
    private DiscoveryClient client; //进行Eureka的发现服务

    @RequestMapping("/discover")
    public Object discover() {//直接返回发现服务信息
        return this.client;
    }

    @GetMapping("/list")
    public List<Test> list() {
        return demoService.list();
    }


    @PostMapping("/save")
    public int save() {
        return demoService.save();
    }
}
